/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package 解析.node.charproperty.支持补集;

import 解析.ASCII;

/**
字符
x	字符 x
\\	反斜线字符
\0n	带有八进制值 0 的字符 n (0 <= n <= 7)
\\0nn	带有八进制值 0 的字符 nn (0 <= n <= 7)
\\0mnn	带有八进制值 0 的字符 mnn（0 <= m <= 3、0 <= n <= 7）
\\xhh	带有十六进制值 0x 的字符 hh
\\uhhhh	带有十六进制值 0x 的字符 hhhh
\t	制表符 ('\u0009')
\n	新行（换行）符 ('\u000A')
\r	回车符 ('\u000D')
\f	换页符 ('\u000C')
\a	报警 (bell) 符 ('\u0007')
\e	转义符 ('\u001B')
\cx	对应于 x 的控制符
 */
public class Single extends BmpCharProperty { 
    public final int c;

    public Single(int c) {
        this.c = c; 
    }
    
    @Override
    public boolean isSatisfiedBy (int ch) {
        return ch == c;
    }
    
    @Override
    public String toString(){
        //return "["+this.getClass().getName()+"]"+new String(new int[]{c},0,1);
        return getSingleString(c);
    }
    
    public static String getSingleString(int c){
        switch(c){
            case 10:return "\\n";
            case 9:return "\\t";
            case 8:return "\\b";
            case 13:return "\\r";
            case 12:return "\\f";
        }
        if(ASCII.isGraph(c))return new String(new int[]{c},0,1);
        return String.format("\\u%04x", c);
    }

    @Override
    public boolean isSatisfiedBy正集(int ch) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public String toString正集() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public String toString补集() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }
}
